<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div style="position: relative;">
    <h3>Tooltips with Vue 3 Teleport</h3>
    <div id="app">

    </div>
  </div>

  <script src="https://unpkg.com/vue@next"></script>
  <script>
    const app = Vue.createApp({
      template: '<div>Hello World</div> <modal-button></modal-button>'
    })
    app.component('child-component', {
      props: ['name'],
      template: `
    <div>Hello, {{ name }}</div>
  `
    })

    app.component('modal-button', {
      template: `
    <button @click="modalOpen = true">
        Open full screen modal!
    </button>

    <teleport to="body">
      <div v-if="modalOpen" class="modal">
        <div>
          I'm a teleported modal! 
          (My parent is "body")
          <child-component name="John" />
          <button @click="modalOpen = false">
            Close
          </button>
        </div>
      </div>
    </teleport>
  `,
      data() {
        return {
          modalOpen: false
        }
      }
    })
    console.log(app)

    app.mount("#app")
  </script>
</body>

</html>